<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="resources/link-highlight-style.css">
    <script src="resources/link-highlight-helper.js"></script>
    <script>
      useMockHighlight();
      if (window.internals)
        internals.settings.setPreferCompositingToLCDTextEnabled(true);

      function runTest() {
        var targetDiv = document.getElementById('targetDiv');
        var resultDiv = document.getElementById('result');

        if (window.internals)
          internals.forceCompositingUpdate(document);

        var clientRect = document.getElementById('targetLink').getBoundingClientRect();
        x = (clientRect.left + clientRect.right) / 2;
        y = (clientRect.top + clientRect.bottom) / 2;
        if (window.testRunner)
          testRunner.waitUntilDone();

        if (window.eventSender) {
          eventSender.gestureShowPress(x, y);
          // FIXME: This is needed to make link highlighting work by marking paint as dirty. crbug.com/415702
          document.querySelector("#targetLink").style.color = "red";
          targetDiv.scrollTop += 20;
          window.setTimeout(function() { testRunner.notifyDone(); }, 30);
        } else {
          debug("This test requires DumpRenderTree.");
        }
      }
    </script>
  </head>
  <body onload="runTest();">
    <div style="will-change: transform; position: relative; left: 10px; top: 10px"></div>
    <div id="targetDiv" style="position: relative; left: 10px; top: 40px; width: 200px; height: 100px; overflow-y: scroll; overflow-x: scroll;">
      <a href="">AAAAAA</a><br>
      <a href="">AAAAAA</a><br>
      <a href="">AAAAAA</a><br>
      <a class="opaqueHighlight" href="" id="targetLink">Target Link.</a><br>
      <a href="">AAAAAA</a><br>
      <a href="">AAAAAA</a><br>
    </div>
    <div style="position: relative; left: 10px; top: 80px">
      This test is successful if "Target Link" above is covered in a green
      rectangle with square corners and the list is partially scrolled.
    </div>
    <div id="result"></div>
  </body>
</html>
